﻿@using doufu.WebUI.Helper
@model doufu.Model.story
<script src="@Url.Content("~/Content/editor/kindeditor.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Content/Scripts/jquery.cookie.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Content/editor/lang/zh_CN.js")" type="text/javascript"></script>
<h2>@(Model.id>0?"修改":"添加")文章</h2>
@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)
    <div class="row-fluid">
        <div class="row">
            <div class="span1">@Html.LabelFor(model => model.story_title)</div>
            <div class="span8">@Html.TextBoxFor(x => x.story_title, new { @class = "span8" }) @Html.ValidationMessageFor(model => model.story_title)</div>
        </div>
        <div class="row">
            <div class="span1">@Html.LabelFor(model => model.story_category)</div>
            <div class="span8">@{Html.StoryCategory("story_category", Model.story_category);}</div>
        </div>
        <div class="row">
            <div class="span1">@Html.LabelFor(model => model.story_content)</div>
            <div class="span8">@Html.TextAreaFor(x => x.story_content, new { style = "width:800px;height:400px" })
                <label class="checkbox inline">
                    <input type="checkbox" onchange="ChgAutoLoad()" name="ContentAutoLoad" id="ContentAutoLoad" />
                    自动加载编辑器
                </label>
            </div>
        </div>
        <div class="row">
            <div class="span1">@Html.LabelFor(model => model.story_seo)</div>
            <div class="span8">@Html.TextBoxFor(x => x.story_seo, new { @class = "span8" })</div>
        </div>
        <div class="row">
            <div class="span1"></div>
            <div class="span8">
                <input type="submit" name="submit" value="保存" class="btn btn-primary" />
            </div>
        </div>
    </div>
}
<script type="text/javascript">
    $(function () {
        var editor;
        var v = $.cookie('is_autoload_edit');
        var bv = (v != null && v != "false");
        $("#ContentAutoLoad").prop("checked", bv);
        if (bv) {
            //$('#story_content').click(function () {
                if (editor == null) {
                    editor = KindEditor.create('textarea[name="story_content"]', {
                        cssPath: ['/Content/css/prettify.css'],
                        uploadJson: '@Url.Action("Upload", "Comm")',
                        urlType: 'absolute'
                    });
                }
            //});
        }
    });
    function ChgAutoLoad() {
        $.cookie('is_autoload_edit', $("#ContentAutoLoad").prop("checked"), { expires: 7 });
    }
</script>
